In [1]:
import pandas as pd
data = pd.read_csv("thanksgiving.csv", encoding="Latin-1")
data.head(1)


Out[1]:
RespondentID Do you celebrate Thanksgiving? What is typically the main dish at your Thanksgiving dinner? What is typically the main dish at your Thanksgiving dinner? - Other (please specify) How is the main dish typically cooked? How is the main dish typically cooked? - Other (please specify) What kind of stuffing/dressing do you typically have? What kind of stuffing/dressing do you typically have? - Other (please specify) What type of cranberry saucedo you typically have? What type of cranberry saucedo you typically have? - Other (please specify) ... Have you ever tried to meet up with hometown friends on Thanksgiving night? Have you ever attended a "Friendsgiving?" Will you shop any Black Friday sales on Thanksgiving Day? Do you work in retail? Will you employer make you work on Black Friday? How would you describe where you live? Age What is your gender? How much total combined money did all members of your HOUSEHOLD earn last year? US Region
0 4337954960 Yes Turkey NaN Baked NaN Bread-based NaN None NaN ... Yes No No No NaN Suburban 18 - 29 Male $75,000 to $99,999 Middle Atlantic

1 rows × 65 columns


In [2]:
data.columns


Out[2]:
Index(['RespondentID', 'Do you celebrate Thanksgiving?',
       'What is typically the main dish at your Thanksgiving dinner?',
       'What is typically the main dish at your Thanksgiving dinner? - Other (please specify)',
       'How is the main dish typically cooked?',
       'How is the main dish typically cooked? - Other (please specify)',
       'What kind of stuffing/dressing do you typically have?',
       'What kind of stuffing/dressing do you typically have? - Other (please specify)',
       'What type of cranberry saucedo you typically have?',
       'What type of cranberry saucedo you typically have? - Other (please specify)',
       'Do you typically have gravy?',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Brussel sprouts',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Carrots',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Cauliflower',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Corn',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Cornbread',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Fruit salad',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Green beans/green bean casserole',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Macaroni and cheese',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Mashed potatoes',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Rolls/biscuits',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Squash',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Vegetable salad',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Yams/sweet potato casserole',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify)',
       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify).1',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Apple',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Buttermilk',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Cherry',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Chocolate',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Coconut cream',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Key lime',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Peach',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pecan',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pumpkin',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Sweet Potato',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - None',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify)',
       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify).1',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Apple cobbler',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Blondies',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Brownies',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Carrot cake',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Cheesecake',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Cookies',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Fudge',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Ice cream',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Peach cobbler',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - None',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify)',
       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify).1',
       'Do you typically pray before or after the Thanksgiving meal?',
       'How far will you travel for Thanksgiving?',
       'Will you watch any of the following programs on Thanksgiving? Please select all that apply. - Macy's Parade',
       'What's the age cutoff at your "kids' table" at Thanksgiving?',
       'Have you ever tried to meet up with hometown friends on Thanksgiving night?',
       'Have you ever attended a "Friendsgiving?"',
       'Will you shop any Black Friday sales on Thanksgiving Day?',
       'Do you work in retail?',
       'Will you employer make you work on Black Friday?',
       'How would you describe where you live?', 'Age', 'What is your gender?',
       'How much total combined money did all members of your HOUSEHOLD earn last year?',
       'US Region'],
      dtype='object')

In [3]:
data['Do you celebrate Thanksgiving?'].value_counts()


Out[3]:
Yes    980
No      78
Name: Do you celebrate Thanksgiving?, dtype: int64

In [4]:
boolean = (data['Do you celebrate Thanksgiving?'] == 'Yes')
data = data.loc[boolean]
data['Do you celebrate Thanksgiving?'].value_counts()


Out[4]:
Yes    980
Name: Do you celebrate Thanksgiving?, dtype: int64

In [5]:
data['What is typically the main dish at your Thanksgiving dinner?'].value_counts()


Out[5]:
Turkey                    859
Other (please specify)     35
Ham/Pork                   29
Tofurkey                   20
Chicken                    12
Roast beef                 11
I don't know                5
Turducken                   3
Name: What is typically the main dish at your Thanksgiving dinner?, dtype: int64

In [6]:
filt_tofur = data[data['What is typically the main dish at your Thanksgiving dinner?'] == 'Tofurkey']
filt_tofur['Do you typically have gravy?']


Out[6]:
4      Yes
33     Yes
69      No
72      No
77     Yes
145    Yes
175    Yes
218     No
243    Yes
275     No
393    Yes
399    Yes
571    Yes
594    Yes
628     No
774     No
820     No
837    Yes
860     No
953    Yes
Name: Do you typically have gravy?, dtype: object

In [7]:
apple_isnull = pd.isnull(data['Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Apple']) 
pumpkin_isnull = pd.isnull(data['Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pumpkin'])
pecan_isnull = pd.isnull(data['Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pecan'])
ate_pies = apple_isnull & pumpkin_isnull & pecan_isnull
ate_pies.value_counts()


Out[7]:
False    876
True     104
dtype: int64

In [8]:
print(data['Age'].value_counts())


45 - 59    269
60+        258
30 - 44    235
18 - 29    185
Name: Age, dtype: int64

In [9]:
def convert(string):
    if pd.isnull(string) == True:
        return None
    else:
        string = string.split(' ')[0]
        answer = string.replace('+', '')
        return int(answer)

data['int_age'] = data["Age"].apply(convert)
data['int_age'].describe()


Out[9]:
count    947.000000
mean      40.089757
std       15.352014
min       18.000000
25%       30.000000
50%       45.000000
75%       60.000000
max       60.000000
Name: int_age, dtype: float64

Despite the fact that we have rounded off the age, the data reflects the present proportions of age groups (the same proportions as in [9])


In [10]:
def income(string):
    if pd.isnull(string) == True:
        return None
    else:
        string = string.split(' ')[0]
        if string == 'Prefer':
            return None
        string = string.replace('$', '')
        string = string.replace(',', '')
        return int(string)
data['int_income'] = data['How much total combined money did all members of your HOUSEHOLD earn last year?'].apply(income)
data['int_income'].describe()


Out[10]:
count       829.000000
mean      75965.018094
std       59068.636748
min           0.000000
25%       25000.000000
50%       75000.000000
75%      100000.000000
max      200000.000000
Name: int_income, dtype: float64

In [11]:
print(data['How much total combined money did all members of your HOUSEHOLD earn last year?'].value_counts())


$25,000 to $49,999      166
$50,000 to $74,999      127
$75,000 to $99,999      127
Prefer not to answer    118
$100,000 to $124,999    109
$200,000 and up          76
$10,000 to $24,999       60
$0 to $9,999             52
$125,000 to $149,999     48
$150,000 to $174,999     38
$175,000 to $199,999     26
Name: How much total combined money did all members of your HOUSEHOLD earn last year?, dtype: int64

When analyzing this result, it should be borne in mind that we took only the lower value of each group. Also, we have a very high standard deviation (59 thousand dollars) with the step size of each group of 25 thousand.


In [12]:
data[data['int_income'] < 50000]['How far will you travel for Thanksgiving?'].value_counts(normalize=True)


Out[12]:
Thanksgiving is happening at my home--I won't travel at all                         0.381295
Thanksgiving is local--it will take place in the town I live in                     0.330935
Thanksgiving is out of town but not too far--it's a drive of a few hours or less    0.230216
Thanksgiving is out of town and far away--I have to drive several hours or fly      0.057554
Name: How far will you travel for Thanksgiving?, dtype: float64

In [13]:
data[data['int_income'] >= 150000]['How far will you travel for Thanksgiving?'].value_counts(normalize=True)


Out[13]:
Thanksgiving is happening at my home--I won't travel at all                         0.471429
Thanksgiving is local--it will take place in the town I live in                     0.242857
Thanksgiving is out of town but not too far--it's a drive of a few hours or less    0.178571
Thanksgiving is out of town and far away--I have to drive several hours or fly      0.107143
Name: How far will you travel for Thanksgiving?, dtype: float64

Only 38 percent of the respondents (with an income of 50000 thousand) celebrate at home. At the same time, 47 percent of respondents (with an income of 150 and above) celebrate at home. Despite not much difference, we can assume that students prefer to celebrate a holiday in the home of parents who earn more (and accordingly, celebrate in their own home).


In [15]:
table = pd.pivot_table(data, values='int_age', index='Have you ever tried to meet up with hometown friends on Thanksgiving night?', columns='Have you ever attended a "Friendsgiving?"')
table


Out[15]:
Have you ever attended a "Friendsgiving?" No Yes
Have you ever tried to meet up with hometown friends on Thanksgiving night?
No 42.283702 37.010526
Yes 41.475410 33.976744

In [16]:
table_income = pd.pivot_table(data, values='int_income', index='Have you ever tried to meet up with hometown friends on Thanksgiving night?', columns='Have you ever attended a "Friendsgiving?"')
table_income


Out[16]:
Have you ever attended a "Friendsgiving?" No Yes
Have you ever tried to meet up with hometown friends on Thanksgiving night?
No 78914.549654 72894.736842
Yes 78750.000000 66019.736842

It appears that young people prefer to meet up with friends on Thanksgiving and try to attend a "Friendsgiving? (We can make this conclusion from pivot tables: people who do this have less age (33.9) and income(66019))

Figure out the most common dessert people eat.


In [18]:
none1 = data['Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify)'].value_counts()
none2 = data['Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify).1'].value_counts()

In [19]:
none1


Out[19]:
Other (please specify)    134
Name: Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify), dtype: int64

In [20]:
none2


Out[20]:
pie                                                    13
Pie                                                    12
pies                                                    6
Pumpkin pie                                             4
pumpkin pie                                             4
chocolate cake                                          3
Pies                                                    3
cake                                                    2
Pumpkin Pie                                             2
Flan                                                    2
pie-spple & pecan                                       1
Cake (not carrot)                                       1
banana pudding                                          1
Other bars                                              1
pie is the dessert                                      1
pistachio ambrosia salad                                1
Date balls                                              1
German Chocolate cake                                   1
choc. cake                                              1
Berry cobbler                                           1
Pound cake                                              1
Just pie                                                1
lemon cake                                              1
bread pudding                                           1
pies selected in previous question (apple, pumpkin)     1
PUMPKIN PIE, OF COURSE                                  1
THE PIE YOU JUST ASKED ABOUT.                           1
Pumpkin                                                 1
Pies and dream whip                                     1
Pound Cake                                              1
                                                       ..
see above                                               1
Pies will do                                            1
ethnic desserts                                         1
chocolate cake or coconut cake                          1
Restaurant with various choices.                        1
as above                                                1
a variety of pies                                       1
Lefse                                                   1
cheesecake.                                             1
Green cake                                              1
pumpkin and pecan pies                                  1
PIES                                                    1
german chocolate cake                                   1
Choc cake                                               1
Chocolate trifle, bread pudding                         1
Pumpkin Roll                                            1
whipped cream for pie                                   1
pumpkin roll                                            1
Pecan pie                                               1
Chocolate Cake                                          1
varies                                                  1
pumpkin pie. why ask this twice?                        1
Pumpkin pie.                                            1
Some sort of chocolate dessert                          1
Lemon Pound, Sour Cream Pound, Rum Cake                 1
Pumpkin roll                                            1
Chocolate Cake with Marshmellows, Caremal Cake          1
chocolate mousse                                        1
Banana Pudding                                          1
Pie only                                                1
Name: Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify).1, dtype: int64

In [21]:
data['Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Peach cobbler'].value_counts()


Out[21]:
Peach cobbler    103
Name: Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Peach cobbler, dtype: int64

In [ ]: